package com.cloudsigns.factorymanager2.media_system.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemCompletionDataListActivity;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemDeviceBindingListActivity;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemDispatchOrderListActivity;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemEditOrderListActivity;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemMaterialUseListActivity;
import com.cloudsigns.factorymanager2.media_system.activity.MediaSystemReceiveOrderFragmentActivity;

public class MediaSystemManagementFragment extends Fragment implements View.OnClickListener {
    private RelativeLayout rl_receive_order, rl_edit_order, rl_dispatch_order, rl_materials_recipients, rl_completion_data, rl_device_binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_media_system_management, null);
        rl_receive_order = view.findViewById(R.id.rl_receive_order);
        rl_edit_order = view.findViewById(R.id.rl_edit_order);
        rl_dispatch_order = view.findViewById(R.id.rl_dispatch_order);
        rl_materials_recipients = view.findViewById(R.id.rl_materials_recipients);
        rl_completion_data = view.findViewById(R.id.rl_completion_data);
        rl_device_binding = view.findViewById(R.id.rl_device_binding);

        rl_receive_order.setOnClickListener(this);
        rl_edit_order.setOnClickListener(this);
        rl_dispatch_order.setOnClickListener(this);
        rl_materials_recipients.setOnClickListener(this);
        rl_completion_data.setOnClickListener(this);
        rl_device_binding.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            // 接收工单
            case R.id.rl_receive_order:
                mIntent = new Intent(getActivity(), MediaSystemReceiveOrderFragmentActivity.class);
                startActivity(mIntent);
                break;
            // 编辑工单
            case R.id.rl_edit_order:
                mIntent = new Intent(getActivity(), MediaSystemEditOrderListActivity.class);
                startActivity(mIntent);
                break;
            // 工单分派
            case R.id.rl_dispatch_order:
                mIntent = new Intent(getActivity(), MediaSystemDispatchOrderListActivity.class);
                startActivity(mIntent);
                break;
            // 材料领用
            case R.id.rl_materials_recipients:
                mIntent = new Intent(getActivity(), MediaSystemMaterialUseListActivity.class);
                startActivity(mIntent);
                break;
            // 完工资料
            case R.id.rl_completion_data:
                mIntent = new Intent(getActivity(), MediaSystemCompletionDataListActivity.class);
                startActivity(mIntent);
                break;
            // 设备绑定
            case R.id.rl_device_binding:
                mIntent = new Intent(getActivity(), MediaSystemDeviceBindingListActivity.class);
                startActivity(mIntent);
                break;
        }
    }
}
